/*
 * JniFileMethodDeclaration.java  0.4.0 / Nov 6, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.tools.ng.jni;

import java.io.PrintWriter;

import com.thoughtworks.qdox.model.JavaMethod;
import com.thoughtworks.qdox.model.JavaParameter;

import com.cute4j.tools.ng.AbstractNativeFile;
import com.cute4j.tools.ng.Utils;

/**
 * JNI File Method Declaration.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public class JniFileMethodDeclaration extends JniFileMethod {

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new JniFileMethod object.
   *
   * @param nativeFile the native file
   * @param method the java method
   * @param overridden <tt>true</tt> if the method is overridden
   */
  public JniFileMethodDeclaration(AbstractNativeFile nativeFile,
                                  JavaMethod method, boolean overridden) {
    super(nativeFile, method, overridden);
  }

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  protected String[] getMethodParameters(JavaMethod javaMethod) {
    JavaParameter[] params = javaMethod.getParameters();
    String[] args = new String[params.length + 2];
    args[0] = "JNIEnv *";
    if (javaMethod.isStatic()) {
      args[1] = "jclass";
    } else {
      args[1] = "jobject";
    }
    for (int i = 0; i < params.length; i++) {
      args[i + 2] = Utils.getJniType(params[i].getType());
    }
    return args;
  }

  /**
   * {@inheritDoc}
   */
  protected void storeBody(PrintWriter pw) {
    pw.println(";");
  }

}
